package com.wjyf.reducing_bento.utils;


import org.springframework.util.DigestUtils;

/**
 * @Author: lrk
 * @Date: 2023/1/11 下午 8:41
 * @Description:
 */
public class Md5Utils {

    public static final String SALT = "$1$asdf";

    /**
     * 比较密码是否相同
     * @param password
     * @param encryptedPassword
     * @return
     */
    public static boolean match(String password, String encryptedPassword) {
        String md5DigestAsHex = DigestUtils.md5DigestAsHex((SALT + password).getBytes());
        return md5DigestAsHex.equals(encryptedPassword);
    }

    /**
     * 加密
     * @param password
     * @return
     */
    public static String encryption(String password) {
        return DigestUtils.md5DigestAsHex((SALT + password).getBytes());
    }

}
